from django.contrib import admin

# Register your models here.
from django.contrib import admin
from .models import Type, Video, UserInfo  # 确保你已经定义了 UserInfo 模型

@admin.register(Type)
class TypeAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'nameid', 'jianjie')
    search_fields = ('name', 'nameid')

@admin.register(Video)
class VideoAdmin(admin.ModelAdmin):
    list_display = ('id', 'get_type_name', 'ctime', 'title', 'source', 'commitNumber', 'agreeNumber', 'watched')
    search_fields = ('title', 'source')
    list_filter = ('type_nameid', 'ctime')

    def get_type_name(self, obj):
        return obj.type_nameid.name
    get_type_name.short_description = '类型'

# admin.site.register(Type)

@admin.register(UserInfo)
class UserInfoAdmin(admin.ModelAdmin):
    list_display = ('id', 'username', 'phone', 'email', 'profile', 'loginip')
    search_fields = ('username', 'phone', 'email')
